#ifndef __BUFFER_H
#define __BUFFER_H

#ifdef  FLVAPI_EXPORTS
#define FLVAPI __declspec(dllexport)
#else
#define FLVAPI __declspec(dllimport)
#endif //*FLVAPI_EXPORTS

typedef unsigned int ui;
typedef unsigned char uc;

#define INIT_BUFFER_SIZE 4096;

static enum {
	BUF_FILE,
	BUF_MEM,
	BUF_STREAM,
	BUF_SET,
	BUF_CUR	
};
struct FLVAPI Buffer {
	ui size;
	ui pos;
	char type;
	int fd;
	uc* data;
};

class FLVAPI CBuffer{
protected:
	CBuffer(){}
public:
	Buffer m_buffer;
	static CBuffer* Create(const char *file, int type);
	void Free();
	int Seek(int off, int mode);
	int Tell();
	const uc* GetData(int size);
	int Copy(CBuffer* src, int src_offset, int size);
	int WriteToFile(const char *file);
	int Flush();
	int Write(const uc* data, int size);
	int Writec(ui val);
	int WriteUI16(ui val);
	int WriteUI24(ui val);
	int WriteUI32(ui val);
	int Readc(ui *c);
	int ReadUI16(ui* ui16);
	int ReadUI24(ui* ui24);
	int ReadUI32(ui* ui32);
};
#endif